

#include <iostream>
#include <vector>

class Test_A {
    public:
        int i;
        Test_A(int m) { this->i = m; }
    protected:
        void print(void) {
            std::cout << "print " << std::endl;
        }
};

int main() {

    Test_A a1(1);
    //a1.print();       //can't pass the compilation
    Test_A a2(2);
    Test_A a3(3);
    Test_A a4(4);

    std::vector<Test_A> test_vector;
    test_vector.push_back(a1);
    test_vector.push_back(a2);
    test_vector.push_back(a3);
    test_vector.push_back(a4);

    for (auto pos = test_vector.cbegin(); pos != test_vector.cend(); ++pos) {

        //pos->i = pos->i + 1; //can't pass the compilation
        std::cout << pos->i << std::endl;
    }


    for (auto pos = test_vector.begin(); pos != test_vector.end(); ++pos) {

        pos->i = pos->i + 1; //can pass the compilation
        std::cout << pos->i << std::endl;
    }

    return 0;
}